<html>
<head>
	<meta charset="UTF-8"/>
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
	<title>吃货餐厅</title>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/metro/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/mobile.css"/>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/icon.css"/>
	<script type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script>
    <script type="text/javascript" src="js/jquery-easyui-1.5/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="js/jquery-easyui-1.5/jquery.easyui.mobile.js"></script>
    
    <script type="text/javascript">
	 /*<![CDATA[*/ 
	            
	var backCount=-1;
	$(document).ready(  
			  function(){
				  $("#car").hide();
				  var flag = $("#flag").val();
				  if(flag=='2')
				  {
					  $("#order").hide();
				  }else
				  {
					  $("#order").show();
				  }
				  
				  $("input[type='checkbox']").click(function(e){
					  stopBubble(e);
					  
					  var count = $("input[type='checkbox']:checked").length;
					  if(count>0)
					  {
						  $("#carnum").html(count);
						  $("#car").show();
						  $("#order").hide();
					  }else
					  {
						  $("#car").hide();
						  $("#order").show();
					  }
					  
				 });
	 });
	 

	function show(obj) 
	{
		$(obj).removeClass('bg');
	} 

	 function clk(obj)
	 {
		  $(obj).toggleClass('bg');
		  setTimeout(function(){show(obj);}, 100);
	 }
	 
	 
	
	 
	 function stopBubble(e) { 
			//如果提供了事件对象，则这是一个非IE浏览器 
			if ( e && e.stopPropagation ) 
			    //因此它支持W3C的stopPropagation()方法 
			    e.stopPropagation(); 
			else
			    //否则，我们需要使用IE的方式来取消事件冒泡 
			    window.event.cancelBubble = true; 
		}
		
	 function removecar()
	 {
		 
		 var orderid = $("#orderid").val();
		 $("input[type='checkbox']").each(function(){ 
			  if($(this).is(':checked')) { 
				  var url = "del_order?id="+$(this).attr("id")+"&orderid="+orderid;
				  
				  $.get(url, function(data){
					  window.location.reload();
				  });
				  
			  }
		  });
		 
		 //var deskid=$("#deskid").val();
         
         //var url ="p_showCar?&deskid="+deskid;
 		 //window.location.href=url;
		  
	 }
	 
	 function ordercar()
	 {
		 
		 var orderid = $("#orderid").val();
		 var url = "order_car?orderid="+orderid;
		  
		  $.get(url, function(data){
			  window.location.reload(); 
		  });
		 
		
	 }
	 
	 
	 
	 function stop(e)
	 {
		 stopBubble(e);
	 }
	 
	 function actionurl(obj)
	 {
		 var orderid = $(obj).attr("name");
		 var foodid = $(obj).attr("id");
		 
		 var url ="p_showEvaluate?&foodid="+foodid+"&orderid="+orderid;
 		 window.location.href=url;
 		 backCount=-2;
	 }
	 
	 function goback()
	 {
		 history.go(backCount);
	 }
	 
	 
	/*]]>*/  
	</script>
   <style type="text/css">
.bg
{
	 background: #E6E6E6;
}

a:link,a:visited{
 text-decoration:none;  /*超链接无下划线*/
}

</style>



</head>
<body>
	<div class="easyui-navpanel">
	
        <header>
            <div class="m-toolbar" >
                <div class="m-title">购物车<span style="font-size: 12px;font-family:'微软雅黑';color: red;"  th:text="'('+${count}+'/'+${amt}+'元'+')'"/></div>
                <div class="m-left">
                    <a href="javascript:void(0)" class="easyui-linkbutton m-back" plain="true" outline="true" onclick="goback()">返回</a>
                </div>
                <div class="m-right" id="car">
                    <a href="javascript:void(0)" class="easyui-linkbutton" plain="true" outline="true" onclick="removecar()"><span style="color: red" id="carnum"/>删&nbsp;&nbsp;除</a>
                </div>
                
                <div class="m-right" id="order">
                    <a href="javascript:void(0)" class="easyui-linkbutton" plain="true" outline="true" onclick="ordercar()">下&nbsp;&nbsp;单</a>
                </div>
               
            </div>
        </header>
        
           <div th:each="food,iterStat:${list}">
          	 		<table border="1"  width="100%" height="100px" style="border-style: solid;border-width: 0 0 1px 0;border-color: #ddd;" th:name="${food.id}" onclick="clk(this)">
          	 			<tr>
          	 				<td style="border: none;" width="50%" height="100px" ><img width="100%" height="100%" th:src="'/myres/'+${food.image}"/></td>
          	 				<td style="border: none;" width="50%" height="100px" >
          	 					<table width="100%" height="100px" th:with="isEven=(${flag} eq '0')" >
          	 					
          	 						<tr><td height="50%" style="border: none;"><span style="font-size: 23px;font-family:'微软雅黑';" th:text="${food.foodname}"/></td><td align="right"><input  th:attr="type=${isEven}?'checkbox':'hidden'" th:id="${food.orderid}" /></td></tr>
          	 						<tr><td height="30%" style="border: none;"><span style="font-size: 20px;color: #009900;font-family:'微软雅黑';" th:text="${food.price}+' 元'"/></td></tr>
          	 						
          	 						<tr><td height="30%" style="border: none;" name="tdclick" onclick="stop(this)">
          	 						  <div  onclick="stop()"><input  class="easyui-numberspinner" th:value="${food.count}" data-options="min:1" style="width:81px;" readonly="readonly"/></div>
          	 						</td>
          	 						<td align="right" th:with="dis=${isEven}?'none':'block'">
          	 							<div  onclick="stop()"><a  th:attr="style='display:'+${dis}+';'"  href="#" th:name="${food.orderid}" th:id="${food.id}"  onclick="actionurl(this)">评&nbsp;价</a></div></td>
          	 						</tr>
          	 						
          	 					</table>
          	 				</td>
          	 			</tr>
          	 		</table>
           </div>
           
	</div>
	
	<input  id="orderid" type="hidden" th:value="${orderid}" />
	<input  id="deskid" type="hidden" th:value="${deskid}" />
	<input  id="flag" type="hidden" th:value="${flag}" />
	
</body>
</html>